package com.example.xd.yunshixun;

import android.app.Application;
import android.content.Context;
import android.widget.Toast;

import com.chinamobile.ysx.YSXError;
import com.chinamobile.ysx.YSXSdk;
import com.chinamobile.ysx.YSXSdkInitializeListener;

import static com.example.xd.yunshixun.Constance.APP_KEY;
import static com.example.xd.yunshixun.Constance.APP_SECRET;

/**
 * @auther XuDan on 2020/3/20.
 */
public class MyApplication extends Application implements YSXSdkInitializeListener {
    public static Application mApp;

    @Override
    public void onCreate() {
        super.onCreate();
        mApp = this;
        initSDK();

    }

    private void initSDK() {
        YSXSdk ysxSdk = YSXSdk.getInstance();
        ysxSdk.initSDK(this, this, APP_KEY, APP_SECRET, this);
    }

    public static Application getMyApplication() {
        return mApp;
    }

    @Override
    public void onYSXSdkInitializeResult(int resultCode, int internalErrorCode) {
        if (resultCode != YSXError.ERROR_SUCCESS) {
            Toast.makeText(mApp, "sdk初始化失败", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(mApp, "sdk初始化成功", Toast.LENGTH_SHORT).show();
        }
    }
}
